public class demo2 {
    public static void main(String[] args) throws InterruptedException {
        Object lock = new Object();
        Thread t1 = new Thread(()->{
            synchronized (lock){
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("正在执行 t1 线程");
            }

        });
        Thread t2 = new Thread(()->{
            synchronized (lock){
                try {
                    lock.wait();
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                System.out.println("正在执行 t2 线程");
            }

        });
        Thread t3 = new Thread(()->{
            synchronized (lock){
                lock.notify();
                lock.notify();
                System.out.println("正在执行 t3 线程");
            }

        });
        t1.start();
        t2.start();
        Thread.sleep(1000);
        t3.start();
    }
}
